package org.kaer.election.utils;

import android.app.Activity;
import android.content.Context;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

/**
 * Created by lizj on 2016/7/29.
 */
public class ActivityUtils {
    private static ArrayList<WeakReference<Context>> weakList = new ArrayList<>();

    public static void addActivity(Context mContext) {
        weakList.add(new WeakReference<Context>(mContext));
    }

    public static void removeActivity(Context mContext) {
        weakList.remove(new WeakReference<Context>(mContext));
    }

    public static void finish() {
        for (int i = 0; i < weakList.size(); i++) {
            ((Activity) weakList.get(i).get()).finish();
        }
    }
}
